<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>for与forEach性能比较</title>
</head>
<body>

    <script>
        var arr = [];
        for(var i = 0;i < 10000; i++) {
            arr.push(i)
        }
        console.time();
        for(var i = 0;i < arr.length; i++) {
            var x = arr[i];
        }
        console.timeEnd();

        console.time();
        arr.forEach(function(o) {
            var x = o;
        })
        console.timeEnd();
    </script>
    
</body>
</html>